<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class UpdateAddressOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('order', function (Blueprint $table) {
            //

            $table->integer('address_copy_id')->unsigned()
                ->default(0)
                ->comment('副本地址id,副本地址是订单生成时的地址，不会随着地址修改而变动');

        });


        Schema::create('address_copy', function (Blueprint $table) {


            $table->bigIncrements('id');
            $table->timestamps();

            $table->integer('user_id')->unsigned()->comment('地址所有者');

            $table->string('name')->default('')->comment('收货人');

            $table->string('phone')->comment('手机号');

            $table->string('address')->comment('地址');

            $table->string('address_index')->comment('表单选中下标');

            $table->string('address_detail')->comment('详细地址');

            $table->string('label')->default('')->comment('标签');


        });

        DB::statement("ALTER TABLE `address_copy` COMMENT='地址副本表'");//表注释

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('order', function (Blueprint $table) {
            //
            $table->dropColumn('address_copy_id');

        });

        Schema::dropIfExists('address_copy');

    }
}
